#GLOBAL
struct VSOutPSIn
{
	float4 Position_VSPS : SV_POSITION0;
	float2 Texcoord_VSPS : TEXCOORD0;
};
float simulateSize;
sampler2D NormalTexture;
sampler2D BackgroundTexture;
#END

#VS
struct VSIn
{
	float3 Position_VS : POSITION0;
	float2 Texcoord_VS : TEXCOORD0;
};


VSOutPSIn main(VSIn In)
{
	VSOutPSIn Out;

	Out.Position_VSPS = float4(In.Position_VS, 1);


	float2 uv = float2(In.Texcoord_VS.x, 1.0-In.Texcoord_VS.y);



	Out.Texcoord_VSPS = uv + (simulateSize * .5);






	return Out;
}
#END

#PS

struct PSOut
{
	float4 Color_PS : SV_TARGET0;
};

PSOut main(VSOutPSIn In)
{
	PSOut Out;

	float4 normal = tex2D(NormalTexture, In.Texcoord_VSPS);
	normal = (normal-0.5) * 2.0;

	float r = tex2D(BackgroundTexture, In.Texcoord_VSPS - (normal.xy * .4)).r;
	float g = tex2D(BackgroundTexture, In.Texcoord_VSPS - (normal.xy * .45)).g;
	float b = tex2D(BackgroundTexture, In.Texcoord_VSPS - (normal.xy * .5)).b;
	Out.Color_PS = float4(r, g, b, 1);

	return Out;
}
#END

